package com.uniandes.modelviewer

class ClassDescriptionsTagLib {
	
	def classDescDivs = { attrs, body ->
		def classes = Class.all

		for(mClass in classes)
		{
			
			def attrList = mClass.getAttributes() as Attribute[]
			out<< "<div id=class."+mClass.id+".d style=\"display:none; text-align:center\">\n"			
			out<< "<h4> "+mClass.name+" </h4>\n"
			for (attr in attrList) {
				out <<"<p>"+ attr.name+"   :   "+attr.value+"</p>\n"
			}
			out <<"<br/>"
			out <<"<b>Relaciones</b><br/>\n"
			def rels = Relation.getAll() as Relation[]
			for (r in rels)
			{
				if(r.from.id.equals(mClass.id))
				{
					out<< "<a onclick=\"changeDesc(\'class."+r.to.id+".d"+"\')\""+" id=\""+"class."+r.to.id+".l"+"\" href=\"#\">"+r.name+"</a><br/>\n"
				}else if (r.to.id.equals(mClass.id))
				{
					out<< "<a onclick=\"changeDesc(\'class."+r.from.id+".d"+"\')\""+"  id=\""+"class."+r.from.id+".l"+"\" href=\"#\">"+r.name+"</a><br/>\n"
				}
			}
			out << "</div>\n"
		}

		
	}
}
